home *** CD-ROM | disk | FTP | other *** search
/ HPAVC / HPAVC CD-ROM.iso / BPNN133U.ZIP / NNTYPE.H < prev    next >
C/C++ Source or Header  |  1992-11-19  |  3KB  |  93 lines

  1. /*
  2. *----------------------------------------------------------------------------
  3. *    file:    nntype.h
  4. *    desc:    define all types for the neural nets
  5. *    by:    patrick ko
  6. *    date:    2 aug 91
  7. *    revi:    v1.2b - 15 jan 92, adaptive coefficients (beta)
  8. *        v1.2u - 17 jan 92, revised data structures
  9. *        v1.31u -20 jan 92, periodic dump
  10. *----------------------------------------------------------------------------
  11. */
  12.  
  13. /*
  14. *    trap multiple nntype include
  15. */
  16. #ifndef    NNTYPE
  17. #define    NNTYPE
  18.  
  19. typedef    int        INTEGER;
  20. typedef    int        FLAG;
  21. typedef    double        REAL;
  22.  
  23. typedef struct    {
  24.     INTEGER    dim;        /* vector dimension */
  25.     REAL    * vect;        /* vector array */
  26.     }    VECTOR;
  27.  
  28. typedef struct    {
  29.     REAL    out;        /* output of unit */
  30.     REAL    net;        /* net product */
  31.     REAL    dlt;        /* for delta dpj*/
  32.     REAL    ndlt;        /* for dpj accumulation (v1.2) */
  33.     VECTOR    *wgtvect;    /* weight vector */
  34.     VECTOR    *dwgtvect1;    /* dweight vector dW at n-1 */
  35.     VECTOR    *dwgtvect2;    /* dweight vector dW at n-2 */
  36.     VECTOR    *dxo;
  37.     REAL    bias;        /* for bias */
  38.     REAL    dbias1;        /* for bias at n-1 */
  39.     REAL    dbias2;        /* for bias at n-2 */
  40.     }    UNIT;
  41.  
  42. typedef struct    {
  43.     INTEGER    dim;        /* number of units */
  44.     UNIT    **unit;        /* array of units */
  45.     }    LAYER;
  46.  
  47. typedef    struct {
  48.     INTEGER    dim;        /* number of layers */
  49.     LAYER    **layer;    /* array of layers */
  50.     }    NET;
  51.  
  52. #define    DimVect(vector)        ((vector)->dim)
  53. #define    Vect(vector)        ((vector)->vect)
  54. #define    Vi(vector,i)        ((vector)->vect[i])
  55.  
  56. #define    Out(unit)        ((unit)->out)
  57. #define    Net(unit)        ((unit)->net)
  58. #define    Dlt(unit)        ((unit)->dlt)
  59. #define    nDlt(unit)        ((unit)->ndlt)
  60. #define    Weight(unit,i)        Vi((unit)->wgtvect,i)
  61. #define    dWeight1(unit,i)    Vi((unit)->dwgtvect1,i)
  62. #define    dWeight2(unit,i)    Vi((unit)->dwgtvect2,i)
  63. #define    vWeight(unit)        ((unit)->wgtvect)
  64. #define    vdWeight1(unit)        ((unit)->dwgtvect1)
  65. #define    vdWeight2(unit)        ((unit)->dwgtvect2)
  66. #define    DO(unit,i)        Vi((unit)->dxo,i)
  67. #define    vDO(unit)        ((unit)->dxo)
  68. #define    Bias(unit)        ((unit)->bias)
  69. #define    dBias1(unit)        ((unit)->dbias1)
  70. #define    dBias2(unit)        ((unit)->dbias2)
  71. #define    DimvWeight(unit)    DimVect(vWeight(unit))
  72.  
  73. #define    DimLayer(layer)        ((layer)->dim)
  74. #define    Unit(layer,i)        ((layer)->unit[i])
  75.  
  76. #define    DimNet(nn)        ((nn)->dim)
  77. #define    Layer(nn,i)        ((nn)->layer[i])
  78. #define DimNetOut(nn)        (DimLayer(Layer(nn,DimNet(nn)-1)))
  79.  
  80. #define ground(x,n)        ((x)<(n)?(n):(x))
  81.  
  82. #define    ETA_DEFAULT        0.50
  83. #define    ALPHA_DEFAULT        0.90
  84. #define LAMBDA_DEFAULT        0.50
  85. #define    ERROR_DEFAULT        0.01
  86. #define    TOLER_DEFAULT        0.001
  87. #define    BACKTRACK_STEP        0.50
  88. #define ME_FLOOR        0.0001
  89. #define    MW_FLOOR        0.0001
  90. #define    ETA_FLOOR        0.0001
  91. #endif
  92.  
  93.